import store from '@/store'

export default function checkPermission(value) {
  if (value && value instanceof Array && value.length > 0) {
    const BG = store.getters && store.getters.BG
    const permissionRoles = value
    if (BG[0] === 'ALL') {
      return true
    } else {
      const hasPermission = BG.some(role => {
        return permissionRoles.includes(role)
      })
      if (!hasPermission) {
        return false
      }
      return true
    }
  } else {
    return false
  }
}
